package com.zerui.manager.web.cmd;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Objects;
import java.util.Set;

/**
 * @Author wh
 * @create_time 2023-05-31 11:00
 */
@Getter
@Setter
@ToString
public class DeviceGroupMoveCmd {

    @ApiModelProperty(value="目标分组id")
    @NotNull(message = "目标分组id")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long targetOrgId;

    @ApiModelProperty(value="设备集合")
    @NotEmpty(message = "设备集合不能为空")
    private Set<GroupNode> groupNodes;

    @Getter
    @Setter
    @ToString
    public static class GroupNode{

        @ApiModelProperty(value="设备id")
        @NotNull(message = "设备id")
        @JsonFormat(shape = JsonFormat.Shape.STRING)
        private Long deviceId;

        @ApiModelProperty(value="原分组id")
        @JsonFormat(shape = JsonFormat.Shape.STRING)
        private Long protoOrgId;


	    @Override
	    public boolean equals(Object o) {
		    if (this == o) {
				return true;
		    }
		    if (o == null || getClass() != o.getClass()) {
				return false;
		    }
		    GroupNode groupNode = (GroupNode) o;
		    return Objects.equals(deviceId, groupNode.deviceId) && Objects.equals(protoOrgId, groupNode.protoOrgId);
	    }

	    @Override
	    public int hashCode() {
		    return Objects.hash(deviceId, protoOrgId);
	    }
    }


}
